#include "mask.hpp"

Mask::Mask(Process *pro):Observer(pro)
{
}

Mask::~Mask()
{
	Log("Release Mask");
	_pro->Detach(this);
}

void Mask::GetMask(Image *_image)
{
	mask = _image;
}

void Mask::Update(Image &image)
{
	omask = Mat(mask->height, mask->width, CV_8UC1, mask->data);
	morphologyEx(omask, omask, MORPH_OPEN, Mat());
	morphologyEx(omask, omask, MORPH_CLOSE, Mat());
	if(ChangeSrcFlag)
		image.CopyTo(image, Image(image.width, image.height, 1, (uint8_t*)omask.data));
		// = Image(omask.cols, omask.rows, 1, (uint8_t*)omask.data);
		//Image(image.width, image.height, 1, (uint8_t*)omask.data)
		//image.CopyTo(image, *mask);
}
